﻿using msBsc.AppLogic.DataAlc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Buyer
{
    public partial class wfOrderInfo : msBsc.Cls.BPCustom
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        //订单详情 列表加载
        public void GetOrderDetail()
        {
            string userid = msBsc.SvRef.UserInfo.Operator;
            if (string.IsNullOrEmpty(userid))
            {
                this.ExecJScript(@"layer.alert('登录过期,请重新登录.', 3);");
                return;
            }
            string orderid = this.GetParamHtValue("orderId");
            if (string.IsNullOrEmpty(orderid))
            {
                this.ExecJScript(@"layer.alert('该订单号不存在,请重新操作.', 3);");
                return;
            }
            int status = 1;
            string message = "原因";
            //获取订单状态是否 是自己的
            using (msBsc.AppLogic.DataAlc.CBizOrdersInfo orderinfo = new AppLogic.DataAlc.CBizOrdersInfo())
            {
                DataSet dsOrderInfo = orderinfo.GetOrderInfoByUserAndOrderId(orderid,userid,false);
                if (dsOrderInfo == null || dsOrderInfo.Tables[0].Rows.Count < 1)
                {
                    this.ExecJScript(@"layer.alert('该订单号不存在,请重新操作.', 3);");
                    return;
                }
                status = Convert.ToInt32(dsOrderInfo.Tables[0].Rows[0]["ORDER_STATUS"].ToString());
                message = dsOrderInfo.Tables[0].Rows[0]["REFUSE_MESSAGE"].ToString();
            }
            using (msBsc.AppLogic.DataAlc.CBizDJkOrdersDetail ordersDetail = new AppLogic.DataAlc.CBizDJkOrdersDetail())
            {
                DataSet ds = ordersDetail.GetOrderDetailsById(orderid, false);
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    this.ExecJScript("$('#detailInfo').html(\"<p style='width: 200px; margin-left: 30px;' class='car-price'>没有查询到任何相关信息...</p>\");$('#divPage').html('');");
                    return;
                }
                string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 1000, "");

                this.ExecJScript(@"setOrderStatus("+status+@");
                            var _html = $('#svc_list_temp_order').html();
                            laytpl(_html).render(" + retJson + @", function (render) {
                                $('#detailInfo').html(render);
                                $('#svc_list_temp_order').remove();
                            }); 
                            var _html2=$('#XmpOperation').html();
                            laytpl(_html2).render(" + retJson + @", function (render) {
                                $('#Operation').html(render);
                                $('#XmpOperation').remove();
                            });setStatus(" + status + ");$('#RefuseMessage').html('" + message + "');");
            }


        }

        
        public override void DoAction()
        {
            if (this.strAction == "init")
            {
                GetOrderDetail();
            }
           
        }
    }
}